ggplot(data=mpg)
ggplot ν¨μλ§μΌλ‘λ κ·Έλνλ₯Ό 그릴 μ μκΈ° λλ¬Έμ μ무κ²λ λμ€μ§
μλλ€.
ggplotμ κ·Έλνλ₯Ό 그리기 μν κΈ°λ³Έ νμ μμ±ν λΏ, λ°μ΄ν°λ₯Ό μ΄λ€
λ°©μμΌλ‘ μκ°νν μ§μ λν μΆκ°μ μΈ μ 보(μ: aes, geom_point, geom_line
λ±)κ° νμνλ€.
dim(mpg)
[1] 234 11
dim()μ μ¬μ©νλ©΄ mpg λ°μ΄ν°μ μ ν(row)κ³Ό μ΄(column) κ°μλ₯Ό νμΈν μ μλ€.
ν: mpg λ°μ΄ν°μ
μλ μ΄ 234κ°μ νμ΄ μλ€.
μ΄: mpg λ°μ΄ν°μ
μλ μ΄ 11κ°μ μ΄μ΄ μλ€.
?mpg
drv
the type of drive train, where f = front-wheel drive, r = rear wheel
drive, 4 = 4wd
drv λ³μλ μλμ°¨μ ꡬλ λ°©μμ λνλΈλ€.
fλ μ λ₯ꡬλ(front-wheel drive),
rλ νλ₯ꡬλ(rear-wheel drive),
4λ μ¬λ₯ꡬλ(four-wheel drive)μ μλ―Ένλ€.
ggplot(data = mpg, aes(x = hwy, y = cyl)) + geom_point()
ggplot(data = mpg, aes(x = class, y = drv)) + geom_point()
classμ drv λ³μλ μ°¨λμ’
λ₯μ ꡬλλ°©μμ΄λΌλ μ΅μ
μ λ³΄λ€ μ λλ§
λνλ΄λ μ«μκ° μλ λ²μ£Όν λ°μ΄ν°μ΄λ€.
λ°λΌμ μΆμΈλ κ΄κ³λ₯Ό νμ
νλλ°μλ μ°μ λλ₯Ό μ΄μ©ν plotμ΄ μ ν©νμ§
μλ€κ³ 보μΈλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = "blue"))
μ½λμμ βblueβκ° λ²μ£Όν κ°μΌλ‘ μΈμλμ΄ μμμΌλ‘ μ μ©λμ§ μμ
κ²μ΄μ΄λ€.
βblueβλ₯Ό λ³μλ‘ κ°μ£Όνμ§ μκ³ κ³ μ λ μμμΌλ‘ μ€μ νλ €λ©΄, aes() ν¨μ
λ°μ color = βblueβλ₯Ό μ§μ ν΄μΌ νλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), color = "blue")
μ΄λ κ² νλ©΄ λͺ¨λ μ μ΄ νλμμΌλ‘ νμλλ©°, λ²μ£Όν κ°μΌλ‘ μλͺ»
λ§€νλμ§ μλλ€.
?mpg
str(mpg)
tibble [234 Γ 11] (S3: tbl_df/tbl/data.frame)
$ manufacturer: chr [1:234] "audi" "audi" "audi" "audi" ...
$ model : chr [1:234] "a4" "a4" "a4" "a4" ...
$ displ : num [1:234] 1.8 1.8 2 2 2.8 2.8 3.1 1.8 1.8 2 ...
$ year : int [1:234] 1999 1999 2008 2008 1999 1999 2008 1999 1999 2008 ...
$ cyl : int [1:234] 4 4 4 4 6 6 6 4 4 4 ...
$ trans : chr [1:234] "auto(l5)" "manual(m5)" "manual(m6)" "auto(av)" ...
$ drv : chr [1:234] "f" "f" "f" "f" ...
$ cty : int [1:234] 18 21 20 21 16 18 18 18 16 20 ...
$ hwy : int [1:234] 29 29 31 30 26 26 27 26 25 28 ...
$ fl : chr [1:234] "p" "p" "p" "p" ...
$ class : chr [1:234] "compact" "compact" "compact" "compact" ...
λ²μ£Όν λ³μ: manufacturer, model, trans, drv, fl, class
μ°μν λ³μ: displ, year, cyl, cty, hwy
?mpgλ₯Ό μ€νν΄ κ° λ³μμ μ€λͺ
μ λ³Ό μ μκ³ ,
str(mpg)λ₯Ό μ€νν΄ κ° λ³μμ λν μ νμ νμΈν΄λ³Ό μ μλ€.
μ΄ λ factorλ‘ νμλ λ³μλ λ²μ£Όν, numμ΄λ intλ‘ νμλ λ³μλ
μ°μνμ΄λ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = hwy, size = hwy))
μ°μν λ³μλ₯Ό μμ(color)μ΄λ
ν¬κΈ°(size)μ λ§€ννλ©΄ μμμ κ·ΈλΌλ°μ΄μ
μΌλ‘, ν¬κΈ°λ
κ°μ λ°λΌ λΉλ‘μ μΌλ‘ 컀μ§κ±°λ μμμ§λ€.
ggplot(data = mpg, aes(x = displ, y = hwy, color = hwy, size = hwy, shape = hwy)) +
geom_point()
νμ§λ§ μ°μν λ³μλ₯Ό λͺ¨μ(shape)μ λ§€ννλ©΄ μμ
κ°μ΄ μ€λ₯κ° λ°μνλ€.
λͺ¨μμ λ³΄ν΅ λ²μ£Όν λ°μ΄ν°λ₯Ό μν΄ μ€κ³λμ΄, κ°μ λ°λΌ κ³ μ ν λͺ¨μμ
μ§μ ν μ μκΈ° λλ¬Έμ΄λ€.
ggplot(data = mpg, aes(x = displ, y = hwy, color = class, size = class, shape = class)) +
geom_point()
μμ κ°μ΄ λ²μ£Όν λ³μλ colorμ shapeμ λ§€νμ΄ μ ν©νλ©°, μμμ΄λ
λͺ¨μμ λ²μ£Όλ³λ‘ λ€λ₯΄κ² μ§μ ν μ μλ€.
sizeμ λ§€ννλ©΄ μλ―Έκ° λͺ¨νΈν΄μ§ μ μλ€.
κ°μ λ³μλ₯Ό μ¬λ¬ μμ±(μ: μμκ³Ό ν¬κΈ°)μ λ§€ννλ©΄ ν΄λΉ λ³μμ λ³νμ λ°λΌ μ¬λ¬ μκ°μ μμκ° λμμ λ¬λΌμ§λ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = hwy, size = hwy))
μμ κ²½μ° hwyμ λ°λΌ μμκ³Ό ν¬κΈ°κ° λμμ λ°λλ€.
μ΄ λ°©λ²μ λ³μκ° κ°μ‘°λμ§λ§ κ°λ
μ±μ΄ λ¨μ΄μ§ μ μλ€.
?geom_point
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy), shape = 21, color = "black", fill = "blue", stroke = 2)
stroke μμ±μ ggplot2μμ μΈκ³½μ λκ»λ₯Ό μ‘°μ νλ
μν μ νλ€.
νΉν, μ±μμκ³Ό μΈκ³½μ μμ κ°κ° μ€μ ν μ μλ
λν(21λ²~24λ²)μλ§ μ μ©λλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy, color = displ < 5))
displ < 5μ²λΌ 쑰건문μ μ¬μ©ν΄ μμμ λ§€ννλ©΄, TRUE/FALSE
λ
Όλ¦¬κ°μΌλ‘ νμλλ€.
κ° κ³ μ κ°μ λν΄ λ³λμ ν¨λμ΄ λ§λ€μ΄μ§λ€. μ°μν λ³μμ κ³ μ κ°μ΄ λ§μ κ²½μ° ν¨λμ΄ λ무 λ§μμ Έ, κ·Έλνκ° λ³΅μ‘νκ³ ν΄μνκΈ° μ΄λ €μμ§ μ μλ€. facetμ μΌλ°μ μΌλ‘ λ²μ£Όν λ³μμ ν¨κ» μ¬μ©ν λ κ°μ₯ μ μ©νλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = drv, y = cyl))
λΉ μ
μ drvμ cylμ νΉμ μ‘°ν©μ΄ λ°μ΄ν°μ μ‘΄μ¬ νμ§ μλλ€λ κ²μ
μλ―Ένλ€.
μμ κ²½μ° μλ₯Ό λ€μ΄, drv=4μΌ λ cyl=5μΈ μ‘°ν©μ μλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_grid(drv ~ .)
μμ κ²½μ°, drv λ³μλ₯Ό ν(row) λ°©ν₯μΌλ‘ fecetνλ€.
κ° drv κ°λ§λ€ νμ΄ λ§λ€μ΄μ§κ³ , displκ³Ό hwy λ³μμ μ°μ λκ° κ° facetμ
λνλλ€.
μ¬κΈ°μ .λ ν΄λΉ λ°©ν₯(μ΄)μ λΉμλλ€λ μλ―Έλ‘ facetμ ν
λ°©ν₯μΌλ‘λ§ λλ λ μ¬μ©νλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_grid(. ~ cyl)
μμ κ²½μ°, cyl λ³μλ₯Ό μ΄(column) λ°©ν₯μΌλ‘ facetνμ¬ κ° cyl κ°λ§λ€
μ΄μ΄ λ§λ€μ΄ μ§λ€.
μ¬κΈ°μ .λ ν΄λΉ λ°©ν₯(ν)μ λΉμλλ€λ μλ―Έλ‘ facetμ μ΄
λ°©ν₯μΌλ‘λ§ λλ λ μ¬μ©νλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_wrap(~ class, nrow = 2)
μ₯μ :
facet_wrapμ ν¨λμ μ¬λ¬ νκ³Ό μ΄μ μλμΌλ‘ λ°°μΉνμ¬, νΉμ λ³μμ κ° κ°μ λν΄ ν¨λμ ꡬμ±ν μ μμ΄ μκ°μ μΌλ‘ κΉλνλ€.
μμ(color)μ μ¬μ©νμ¬ λ³μλ³λ‘ ꡬλΆνλ λμ , facetμ μ¬μ©νλ©΄ λ λͺ
ννκ² λΉκ΅ν μ μλ€.
λ¨μ :
facetμ κ°μκ° λ§μμ§ κ²½μ° μ 체 plotμ΄ λ³΅μ‘ν΄μ§ μ μκ³ , νΉν λ°μ΄ν°κ° ν° κ²½μ° νλ©΄ 곡κ°μ λ§μ΄ μ°¨μ§ν μ μλ€.
ν¨λλ‘ λλ κ²½μ°, μ 체μ μΈ λ°μ΄ν° λΆν¬λ₯Ό λμμ λΉκ΅νκΈ° μ΄λ €μΈ μ μλ€.
λ°μ΄ν° μ μ΄ λ μ»€μ§ κ²½μ°:
λ°μ΄ν°κ° λ 컀μ§λ€λ©΄ μμ ꡬλΆμ΄ λ ν¨κ³Όμ μΌ μ μλ€. facetμ μ λΉν λ²μ£Όμ λ°μ΄ν° μ
μμ λ μ μ©ν κ²μ΄λ€.
?facet_wrap
facet_wrapμμ nrowλ ν(row)μ κ°μλ₯Ό μ§μ νκ³ , ncolμ μ΄(column)μ
κ°μλ₯Ό μ§μ νλ€. μ΄ μ΅μ
μ ν΅ν΄ ν¨λμ λ°°μΉλ₯Ό μ‘°μ ν μ μλ€.
μΆκ°λ‘ scales μ΅μ
μ μ¬μ©νμ¬ κ° ν¨λμ μΆ λ²μλ₯Ό μ‘°μ ν μ μλ€.
facet_gridλ νκ³Ό μ΄λ‘ κ³ μ λ 격μ ννλ‘ facetμ λ§λ€κΈ° λλ¬Έμ
nrowμ ncol μ΅μ
μ΄ μλ€. facet_gridλ μΌλ°μ μΌλ‘ λ κ°μ λ²μ£Όν λ³μ κ°
κ΄κ³λ₯Ό μκ°νν λ μ¬μ©νλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_grid(drv ~ .)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_grid(. ~ drv)
첫 λ²μ§Έ plotμ drvλ₯Ό ν λ°©ν₯μΌλ‘ facetνκ³ , λ λ²μ§Έ νλ‘―μ drvλ₯Ό μ΄
λ°©ν₯μΌλ‘ facetνλ€.
λ plot μ€μλ 첫λ²μ§Έ plotμ΄ λΉκ΅νκΈ° λ μ½λ€.
첫 λ²μ§Έ plotμμλ drv λ³μμ λ°λΌ ν λ°©ν₯μΌλ‘ ν¨λμ΄ λλμ΄ κ° κ΅¬λ
λ°©μλ³ λ°μ΄ν°κ° ν νμ μ λ ¬λλ―λ‘, μμλλ‘ λΉκ΅νκΈ°κ° λ μ§κ΄μ μ΄λ€.
μ¦, κ° κ΅¬λ λ°©μμ μμ§ ν¬κΈ° λΆν¬λ₯Ό μμ§μΌλ‘ λ°°μΉνμ¬ λΉ λ₯΄κ² λΉκ΅ν μ
μλ€.
λ°λ©΄, λ λ²μ§Έ plotμ drvλ₯Ό μ΄ λ°©ν₯μΌλ‘ ν¨λμ λλ΄μΌλ―λ‘, μ’μ°λ‘
λΉκ΅ν΄μΌ νλ€. μ΄ κ²½μ°, μκ°μ μΌλ‘ λΉκ΅νλ λ° λ λ§μ μ΄λμ΄ νμν΄
μ΄ν΄νκΈ°κ° λΆνΈν μ μλ€.
μμ μμλ λΉκ΅νλ €λ λ³μλ₯Ό ν λ°©ν₯μΌλ‘ λ°°μΉνλ κ²μ΄
μ§κ΄μ μ΄λΌλ κ²μ 보μ¬μ€λ€. νμ§λ§ facetλ³μκ° λ§κ±°λ κ°λ‘λ‘ λμ΄νλ
κ²μ΄ λ μ ν©ν κ²½μ°λ μ΄λ°©ν₯μΌλ‘ λ°°μΉν μλ μλ€. λ°λΌμ λ³μλ₯Ό νκ³Ό μ΄
μ€ μ΄λ λ°©ν₯μΌλ‘ λ°°μΉν μ§λ λΉκ΅νλ €λ λ°μ΄ν°μ νΉμ±κ³Ό μκ°μ μΌλ‘ λΉκ΅κ°
λ μ¬μ΄ λ°©ν₯μ κ³ λ €νμ¬ κ²°μ ν΄μΌ νλ€.
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_grid(drv ~ .)
ggplot(data = mpg) +
geom_point(mapping = aes(x = displ, y = hwy)) +
facet_wrap(~ drv)
μμ κ²½μ°, facet_wrap()μ ν¨λμ μλμΌλ‘ λ°°μΉνλ©°, κ° ν¨λμ λΌλ²¨
μμΉκ° μμͺ½ μ€μμ λνλλ€.
facet_grid(drv ~ .)μμμ λ¬λ¦¬ ν¨λμ΄ ν λλ μ΄λ‘λ§ λ°°μΉλμ§ μκ³ ,
μ¬μ©μκ° μ§μ ν nrow λλ ncolμ λ°λΌ ν¨λ λ°°μΉλ₯Ό μ‘°μ ν μ μλ€.
μ κ·Έλν (Line chart): geom_line()
λ°μ€ νλ‘― (Boxplot): geom_boxplot()
νμ€ν κ·Έλ¨ (Histogram): geom_histogram()
λ©΄μ κ·Έλν (Area chart): geom_area()
κ° drvλ³λ‘ λ€λ₯Έ μμμ μ μ΄ λνλκ³ , κ° μμμ ν΄λΉνλ 곑μ μ΄
μΆκ°λ κ²μ΄λ€.
se = FALSEλ μ λ’° ꡬκ°μ νμνμ§ μλλ‘ μ€μ ν΄ smmoth 곑μ μ μ λ’° ꡬκ°
μμμ΄ μμ κ²μ΄λ€.
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) +
geom_point() +
geom_smooth(se = FALSE)
show.legend = FALSEλ λ²λ‘(legend)λ₯Ό μ¨κΈ΄λ€.
μ΄κ²μ μ κ±°νλ©΄ λ²λ‘κ° λ€μ νμλλ€.
μ±
μμ μ΄λ₯Ό μ¬μ©ν μ΄μ λ μκ°νμμ λ²λ‘κ° νμνμ§ μλ€κ³ νλ¨νκ±°λ
μκ°μ λ¨μννκΈ° μν΄μμΌ κ²μ΄λ€.
se = TRUEλ‘ μ€μ νλ©΄ smmoth 곑μ μ£Όμμ μ λ’° ꡬκ°μ λνλ΄λ μμμ΄
μΆκ°λλ€.
κΈ°λ³Έκ°μ TRUEμ΄κ³ , se = FALSEλ‘ μ€μ νλ©΄ μ λ’° ꡬκ°μ μ κ±°νμ¬ κ³‘μ λ§
νμλλ€.
ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_point() +
geom_smooth()
ggplot() +
geom_point(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_smooth(data = mpg, mapping = aes(x = displ, y = hwy))
λ κ·Έλνλ λμΌνκ² λ³΄μΌ κ²μ΄λ€. μλνλ©΄ λ μ½λ λͺ¨λ λμΌν
λ°μ΄ν°λ₯Ό μ¬μ©νμ¬ κ°μ μ°μ λμ smooth 곑μ μ 그리기 λλ¬Έμ΄λ€.
첫 λ²μ§Έ μ½λμμλ λ°μ΄ν°μ λ§€νμ ggplot() ν¨μμμ μ€μ νμ§λ§, λ λ²μ§Έ
μ½λμμλ κ°κ°μ geom ν¨μμμ μ€μ νμ΅λλ€. μκ°μ μΌλ‘λ μ°¨μ΄κ°
μμΌλ, λ λ²μ§Έ λ°©λ²μ΄ λ λͺ
μμ μ΄λΌκ³ ν μ μλ€.
ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(color = "black") +
geom_smooth(se = FALSE)
ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
geom_point(color = "black") +
geom_smooth(aes(group = drv), color = "blue", se = FALSE)
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) +
geom_point() +
geom_smooth(se = FALSE)
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) +
geom_point() +
geom_smooth(se = FALSE, color = "blue")
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, color = drv)) +
geom_point() +
geom_smooth(aes(linetype = drv), se = FALSE)
ggplot(data = mpg, mapping = aes(x = displ, y = hwy, fill = drv)) +
geom_point(size = 4, shape = 21, color = "white", stroke = 1.5)
stat_summary()μ κΈ°λ³Έ geomμ geom_pointrange()μ΄λ€. stat_summary()λ
μμ½ ν΅κ³λ₯Ό 그릴 λ μ¬μ©λλ©°, μ£Όλ‘ νκ· κ³Ό μ λ’° κ΅¬κ° λ±μ νμν λ
μ μ©νλ€.
stat_summary() λμ κΈ°λ³Έ geomμ μ¬μ©νκ³ μΆλ€λ©΄ geom_pointrange()λ₯Ό
μ¬μ©ν μ μλ€.
ggplot(data = diamonds) +
geom_pointrange(
mapping = aes(x = cut, y = depth, ymin = ..ymin.., ymax = ..ymax..),
stat = "summary",
fun.min = min,
fun.max = max,
fun = median
)
ggplot(data = diamonds) +
geom_pointrange(mapping = aes (x = cut, y = depth, ymin =depth, ymax =depth))
geom_col()μ xμΆκ³Ό yμΆμ κ°μ κ·Έλλ‘ μ¬μ©ν΄ λ§λ κ·Έλνλ₯Ό κ·Έλ¦°λ€. μ¦, λ°μ΄ν° νλ μ λ΄μ μ΄λ―Έ yμΆ κ°μ΄ μλ κ²½μ° geom_col()μ μ¬μ©νμ¬ κ·Έ κ°μ κ·Έλλ‘ λ§λμ λμ΄λ‘ λνλΈλ€.
geom_bar()λ yκ°μ΄ μ£Όμ΄μ§μ§ μμΌλ©΄ μλμΌλ‘ λ°μ΄ν°μ κ°μλ₯Ό μΈμ΄
λΉλ λ§λ κ·Έλνλ₯Ό κ·Έλ¦°λ€. μ¦, geom_bar()λ stat = βcountβκ° κΈ°λ³Έ
μ€μ μ΄λ©°, λ³λμ yκ°μ΄ νμνμ§ μλ€.
λλΆλΆμ geomκ³Ό statμ pairμ μ΄λ£¨λ©°, λμΌν λ°μ΄ν° λ³νκ³Ό μκ°ν
λͺ©μ μ κ°μ§κ³ μλ€. μλ₯Ό λ€μ΄, geom_bar()λ stat_count()μ ν¨κ»
μ¬μ©λλ©°, geom_smooth()λ stat_smooth()μ ν¨κ» μ¬μ©λλ€.
μ£Όμμμ:
geom_bar() β stat_count()
geom_col() β stat_identity()
geom_histogram() β stat_bin()
geom_density() β stat_density()
geom_boxplot() β stat_boxplot()
geom_smooth() β stat_smooth()
geom_point() β stat_identity()
geom_line() β stat_identity()
geom_violin() β stat_ydensity()
geom_pointrange() β stat_summary()
geom_errorbar() β stat_summary()
geom_ribbon() β stat_summary()
http://ggplot2.tidyverse.org/reference/ ν΄λΉ λ§ν¬λ₯Ό μ°Έκ³ ν μ μλ€.
stat_smooth()μ μ£Όμ variables:
y
ymin
ymax
μ£Όμ parameter:
method: smoothν¨μλ₯Ό μ ννλ μ΅μ
se: μ λ’° ꡬκ°μ νμν μ§ μ¬λΆλ₯Ό κ²°μ νλ©°, TRUE λλ FALSEλ‘ μ€μ
level: μ λ’° ꡬκ°μ μμ€μ μ€μ ν©λλ€ (μ: 0.95λ 95% μ λ’° ꡬκ°).
span: method = "loess"μΌ λ 곑μ μ smoothnessμ μ μ΄.
ggplot(data = mpg, aes(x = displ, y = hwy)) +
geom_point(aes(color = drv)) +
stat_smooth(se = FALSE)
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, y = after_stat(prop)))
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, fill = color, y = after_stat(prop)))
λΉμ¨ λ§λ κ·Έλνμμ group = 1μ μ€μ νλ μ΄μ λ xμΆμ κ° λ²μ£Όκ° λ 립μ μΈ κ·Έλ£ΉμΌλ‘ κ°μ£Όλλλ‘ νκΈ° μν¨μ΄λ€. group = 1μ μ€μ νμ§ μμΌλ©΄ κ° λ²μ£Όκ° κ°λ³μ μΌλ‘ κ³μ°λμ§ μκΈ° λλ¬Έμ μνλ λΉμ¨μ΄ λνλμ§ μκ² λλ€.
μ λ κ·Έλνμ λ¬Έμ μ μ λΉμ¨μ΄ μ λλ‘ κ³μ°λμ§ μλλ€λ κ²μ΄μ΄λ€.μ΄ λ κ·Έλνμμλ group = 1μ μ€μ νμ§ μμ κ° cutμ κ°λ€μ΄ λ³λλ‘ κ·Έλ£Ήνλμ§ μμλ€. κ²°κ³Όμ μΌλ‘ propμ΄ μ 체 λ°μ΄ν°λ₯Ό λμμΌλ‘ κ³μ°λμ΄, κ° cutμ λΉμ¨μ΄ μ¬λ°λ₯΄κ² νμλμ§ μλλλ€. group = 1μ μΆκ°νμ¬ κ° cut λ²μ£Όκ° λ 립μ μΈ κ·Έλ£ΉμΌλ‘ κ³μ°λλλ‘ ν΄μΌ μ¬λ°λ₯Έ λΉμ¨μ΄ νμλλ€.
ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
geom_point()
λ¬Έμ μ : μ¬λ¬ λ°μ΄ν° ν¬μΈνΈκ° λμΌν μμΉμ μμ΄μ κ²ΉμΉκΈ° λλ¬Έμ λͺ¨λ λ°μ΄ν°λ₯Ό νμΈν μ μλ€. κ²ΉμΉ μ λ€μ΄ λ§μ μ€μ λ°μ΄ν°λ³΄λ€ μ μ μ λ€μ΄ 보μ΄κ² λλ€.
κ°μ λ°©λ²: geom_jitter()λ₯Ό μ¬μ©νμ¬ μ λ€μ μ½κ°μ© ν©μ΄μ§κ² νλ©΄ κ²ΉμΉλ λ¬Έμ λ₯Ό μ€μ΄κ³ λ°μ΄ν°λ₯Ό λ μ μκ°νν μ μλ€.
ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
geom_jitter()
geom_jitter()μμ μ λ€μ΄ ν©μ΄μ§λ μ λλ widthμ height νλΌλ―Έν°λ‘ μ μ΄ν μ μλ€.
ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
geom_jitter(width = 0.2, height = 0.2)
# geom jitter
ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
geom_jitter()
# geom count
ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
geom_count()
geom_jitter(): μ λ€μ μ½κ°μ© ν©μ΄μ§κ² νμ¬ μκ°ννλ€. κ° λ°μ΄ν° ν¬μΈνΈλ μ½κ°μ λ³μκ° μ μ©λμ΄ νμλλ€.
geom_count(): λμΌν μμΉμ μ¬λ¬ λ°μ΄ν° ν¬μΈνΈκ° μμ κ²½μ°, μ μ ν¬κΈ°λ₯Ό κ·Έ κ°μμ λΉλ‘νμ¬ νμνλ€. κ°μ μμΉμ λ§μ λ°μ΄ν°κ° μμμλ‘ μ μ΄ μ»€μ§λ€.
μ¦, geom_jitter()λ μ λ€μ ν©μ΄μ§κ²ν΄ λ°μ΄ν°λ₯Ό λΆλ¦¬νμ§λ§, geom_count()λ μ μ ν¬κΈ°λ‘ λ°μ΄ν°μ μ€λ³΅μ νννλ€.
geom_boxplot()μ κΈ°λ³Έ μμΉ μ‘°μ λ°©μμ position = βdodgeβμ΄λ€. μ΄ μμΉ μ‘°μ λ°©μμ κ° λ²μ£Όμ λν΄ λ°μ€ νλ‘―μ λλν λ°°μΉνμ¬ μλ‘ κ²ΉμΉμ§ μλλ‘ νλ€.
ggplot(data = mpg, mapping = aes(x = drv, y = hwy, fill = drv)) +
geom_boxplot()
ggplot(data = diamonds, aes(x = factor(1), fill = cut)) +
geom_bar(width = 1) +
coord_polar(theta = "y") +
labs(x = NULL, y = NULL)
labs() λ κ·Έλνμ λ μ΄λΈμ μ€μ νλ ν¨μλ‘, μΆ μ λͺ©, κ·Έλν μ λͺ©,
λ²λ‘ μ λͺ© λ±μ λ³κ²½ν μ μλ€.
labs()λ title, subtitle, caption, x, y, fill, color λ±μ λ§€κ°λ³μλ₯Ό
μ¬μ©ν΄ κ·Έλνμ λ€μν μμμ μ λͺ©μ μΆκ°νκ±°λ λ³κ²½ν μ μλ€.
coord_quickmap(): μ§λλ₯Ό 그릴 λ μ§λ¦¬μ λΉμ¨μ λΉ λ₯΄κ² μ€μ νλ€. κ³μ°μ λ¨μννμ¬ λΉμ¨μ΄ μ νν λ§μ§ μμ§λ§, μλκ° λΉ λ₯΄λ€. μΌλ°μ μΌλ‘ μ§λκ° νλ©΄μ μ μ ν λΉμ¨λ‘ 보μ΄λλ‘ μ‘°μ νλ€.μ§μ μ΄ μ μ§λμ§ μλλ€.
coord_map(): μ§λ¦¬μ λΉμ¨μ μ ννκ² μ‘°μ νλ©°, λ€μν ν¬μλ²μ μ¬μ©ν μ μμ΅λλ€. κ³μ°μ΄ λ 볡μ‘νκ³ μκ°μ΄ μ€λ 걸리μ§λ§, λΉκ΅μ μ νν μ§λ¦¬μ λΉμ¨μ μ 곡νλ€. μ§μ μ (λλΆλΆ) μ μ§νλ€.
ggplot(data = mpg, mapping = aes(x = cty, y = hwy)) +
geom_point() +
geom_abline() +
coord_fixed()
μ΄ plotμ cty(λμ μ°λΉ)μ hwy(κ³ μλλ‘ μ°λΉ) μ¬μ΄μ μμ μκ΄ κ΄κ³κ° μμμ 보μ¬μ€λ€. μ¦, ctyκ° λμμλ‘ hwyλ λμμ§λ κ²½ν₯μ΄ μλ€.
coord_fixed()μ μ€μμ±: coord_fixed()λ xμΆκ³Ό yμΆμ λΉμ¨μ 1:1λ‘ κ³ μ νμ¬, λ μΆμ λ¨μκ° λμΌν λΉμ¨λ‘ νμλλλ‘ νλ€. μ΄λ₯Ό ν΅ν΄ geom_abline()μμ μΆκ°ν λκ°μ (κΈ°μΈκΈ° 1μ μ )μ΄ μ νν 45λ κ°λλ‘ λνλλ©°, ctyμ hwyμ κ΄κ³λ₯Ό λ μ§κ΄μ μΌλ‘ μ΄ν΄ν μ μλ€. λΉμ¨μ΄ κ³ μ λμ§ μμΌλ©΄, μΆμ λΉμ¨ μ°¨μ΄λ‘ μΈν΄ κ΄κ³κ° μ곑λ μ μλ€.
geom_abline()μ μν : geom_abline()μ κΈ°λ³Έμ μΌλ‘ κΈ°μΈκΈ°κ° 1μ΄κ³ μ νΈμ΄ 0μΈ λκ°μ μ μΆκ°νμ¬, xμ yκ° κ°μ κ°μΌ λμ κΈ°μ€μ μ λνλΈλ€. μ΄ μ μ κΈ°μ€μΌλ‘ λ°μ΄ν°λ₯Ό λΉκ΅ν μ μμΌλ©°, μ΄ κ²½μ° ctyμ hwyμ κ΄κ³λ₯Ό νκ°νλ λ° λμμ μ€λ€.
Had an arrival delay of two or more hours
Flew to Houston (IAH or HOU)
Were operated by United, American, or Delta
Departed in summer (July, August, and September)
Arrived more than two hours late, but didnβt leave late
Were delayed by at least an hour, but made up over 30 minutes in flight
library(nycflights13)
library(dplyr)
flights %>%
filter(arr_delay >= 120, # Had an arrival delay of two or more hours
dest %in% c("IAH", "HOU"), # Flew to Houston (IAH or HOU)
carrier %in% c("UA", "AA", "DL"), # Were operated by United, American, or Delta
month %in% c(7, 8, 9), # Departed in summer (July, August, and September)
arr_delay > dep_delay, # Arrived more than two hours late, but didnβt leave late
dep_delay >= 60, arr_delay - dep_delay > 30) # Were delayed by at least an hour, but made up over 30 minutes in flight
κ°μ₯ κΈ΄ μΆλ° μ§μ°μ΄ μλ ν곡νΈ
flights %>%
arrange(desc(dep_delay))
κ°μ₯ μ΄λ₯Έ μκ°μ μΆλ°ν ν곡νΈ
flights %>%
arrange(dep_time) %>%
filter(!is.na(dep_time))
λΉν μλλ₯Ό κΈ°μ€μΌλ‘ μ λ ¬ν μ μλ€. μλλ distance(거리)λ₯Ό air_time(λΉν μκ°)μΌλ‘ λλμ΄ κ³μ°ν μ μλ€.
flights %>%
mutate(speed = distance / (air_time / 60)) %>%
arrange(desc(speed))
NA
κ°μ₯ λ©λ¦¬ μ΄λν ν곡νΈ
flights %>%
arrange(desc(distance))
κ°μ₯ μ§§κ² μ΄λν ν곡νΈ
flights %>%
arrange(distance)
filter()μ arrange()μ μμκ° μ€μν μ μλ€.
filter()λ‘ λ¨Όμ λ°μ΄ν°λ₯Ό μ€μ΄λ©΄ arrange()κ° μ λ ¬ν΄μΌ ν λ°μ΄ν° μμ΄
μ€μ΄λ€μ΄ μμ
μλκ° λΉ¨λΌμ§ μ μλ€.
arrange()λ₯Ό λ¨Όμ μ¬μ©νλ©΄ μ 체 λ°μ΄ν°μ
μ μ λ ¬ν ν νν°λ§νλ―λ‘
λΆνμν κ³μ°μ΄ λ°μν μ μλ€.
λ°λΌμ, μΌλ°μ μΌλ‘ filter()λ₯Ό λ¨Όμ μ¬μ©νμ¬ λ°μ΄ν°λ₯Ό μ€μΈ ν
arrange()λ₯Ό μ¬μ©νλ κ²μ΄ λ ν¨μ¨μ μ΄λ€.
flights <- flights %>%
mutate(
dep_time_mins = (dep_time %/% 100) * 60 + (dep_time %% 100),
sched_dep_time_mins = (sched_dep_time %/% 100) * 60 + (sched_dep_time %% 100)
)
flights
NA
air_timeμ μ€μ λΉν μκ°(λΆ λ¨μ)μ λνλΈλ€.
λ°λ©΄, arr_time - dep_timeμ μΆλ° μκ°κ³Ό λμ°© μκ°μ λΉΌμ μ»μ κ°μ΄λ―λ‘
μ νν λΉν μκ°μ λνλ΄μ§ μμ μ μλ€.
λ°λΌμ arr_timeκ³Ό dep_timeλ HHMM νμμ΄λ―λ‘, μ΄ κ°μ λΆμΌλ‘ λ³νν΄μΌ
νλ€.
flights <- flights %>%
mutate(
dep_time_mins = (dep_time %/% 100) * 60 + (dep_time %% 100),
arr_time_mins = (arr_time %/% 100) * 60 + (arr_time %% 100),
air_time_calculated = arr_time_mins - dep_time_mins
)
# λΉκ΅
flights %>%
select(air_time, air_time_calculated)
NA
flights %>% select(dep_time, dep_delay, arr_time, arr_delay)
NA
flights %>% select(contains("dep"), contains("arr"))
NA
flights %>% select(starts_with("dep"), starts_with("arr"))
NA
flights %>% select(matches("^(dep|arr)_(time|delay)"))
NA
variables <- c("dep_time", "dep_delay", "arr_time", "arr_delay")
flights %>% select(all_of(variables))
NA
flights %>% select(4, 6, 7, 9) # dep_time, dep_delay, arr_time, arr_delay
NA
select() ν¨μμμ λμΌν λ³μ μ΄λ¦μ μ¬λ¬ λ² ν¬ν¨νλ©΄, κ²°κ³Όμλ ν΄λΉ
λ³μκ° ν λ²λ§ μ νλλ€.
dplyrμ select()μμ μ€λ³΅λ λ³μ μ΄λ¦μ μλμΌλ‘ μ κ±°νμ¬, κ²°κ³Όμ
μ€λ³΅λμ§ μλλ‘ μ²λ¦¬νλ€.
variables <- c("year", "month", "day", "dep_delay", "arr_delay")
variables
[1] "year" "month"
[3] "day" "dep_delay"
[5] "arr_delay"
any_of()λ dplyrμ ν¬νΌ ν¨μλ‘, μ§μ λ μΉΌλΌ μ΄λ¦ λͺ©λ‘ μ€ μ€μ λ°μ΄ν°μ μ μ‘΄μ¬νλ μΉΌλΌλ§ μ νν μ μλλ‘ ν΄μ€λ€.
μ¦, μ§μ ν μΉΌλΌ μ΄λ¦ μ€ μΌλΆκ° λ°μ΄ν°μ μ μμ΄λ μ€λ₯λ₯Ό λ°μμν€μ§ μκ³ , μ€μ λ‘ μ‘΄μ¬νλ μΉΌλΌλ§ μ ννλ€.
any_of()κ° μ μ©ν μ΄μ :
μ£Όμ΄μ§ 벑ν°κ° μμ μ½λμ κ°μ λ, select(flights, any_of(variables))μ κ°μ΄ μ¬μ©νλ©΄ flights λ°μ΄ν°μ
μ ν¬ν¨λ variablesμ μΉΌλΌλ§ μ νλλ€. 벑ν°μ μλ λͺ¨λ μΉΌλΌμ΄ flights λ°μ΄ν°μ
μ μμ΄λ μ€λ₯κ° λ°μνμ§ μμΌλ©°, λ°μ΄ν°μ
μ μ‘΄μ¬νλ μΉΌλΌλ§ μ νλλ€.
μ¦, μ½λ μ μ°μ±, μ½λ μ¬μ¬μ©μ±.
select(flights, contains("TIME")) #λ€μ
contains() ν¨μκ° λμλ¬Έμ ꡬλΆμ΄ μλλ€.
λμλ¬Έμλ₯Ό ꡬλΆνμ¬ κ²μνλ €λ©΄ ignore.case = FALSE
μ΅μ
μ μΆκ°ν μ μλ€.
select(flights, contains("TIME", ignore.case = FALSE))
carrier_delays <- flights %>%
group_by(carrier) %>%
summarise(avg_dep_delay = mean(dep_delay, na.rm = TRUE)) %>%
arrange(desc(avg_dep_delay))
carrier_delays
worst delays: F9
carrier_dest_counts <- flights %>%
group_by(carrier, dest) %>%
summarise(count = n(), avg_dep_delay = mean(dep_delay, na.rm = TRUE)) %>%
arrange(desc(avg_dep_delay))
`summarise()` has grouped output by 'carrier'. You can override using the `.groups` argument.
carrier_dest_counts
NA
νΉμ ν곡μ¬-곡ν μ‘°ν©μμμ νκ· μ§μ° μκ°μ νμΈν μ μλ€. νμ§λ§
μ΄ λ°©μμΌλ‘ 곡νκ³Ό νκ³΅μ¬ κ°μ μ§μ° μμΈμ μλ²½νκ² κ΅¬λΆνλ κ²μ
μ΄λ ΅λ€. μλ₯Ό λ€μ΄, ν곡기 μ€μΌμ€μ΄λ νΉμ μκ°λμ νΌμ‘λ, λ μ¨ λ±μ
λ€λ₯Έ μμλ€λ μ§μ°μ μν₯μ λ―ΈμΉκΈ° λλ¬Έμ, λ¨μν 곡νκ³Ό ν곡μ¬λ§μ
λΉκ΅ν΄μλ μ 체μ μΈ μ§μ° μμΈμ λͺ
ννκ² κ΅¬λΆνκΈ° μ΄λ ΅λ€. μ§μ° μμΈμ
μμ ν μ΄ν΄νλ €λ©΄ λ λ§μ λ³μλ₯Ό κ³ λ €ν΄μΌ νλ€.
count() ν¨μμ sort = TRUE μΈμλ₯Ό μ¬μ©νλ©΄, κ²°κ³Όκ° μλμΌλ‘ μΉ΄μ΄νΈκ° ν° μμλλ‘ μ λ ¬λλ€.
carrier_counts <- flights %>%
count(carrier, sort = TRUE)
carrier_counts
sort = TRUEλ arrange(desc(n))μ κ°μ κΈ°λ₯μ μννλ€κ³ λ§ν μ μλ€.
carrier_counts <- flights %>%
count(carrier) %>%
arrange(desc(n)) #λ΄λ¦Όμ°¨μ μ λ ¬
carrier_counts
read_delim()
read_delim("data/students.csv", delim = "|", show_col_types = FALSE)
intersect(names(formals(read_csv)), names(formals(read_tsv)))
[1] "file" "col_names" "col_types" "col_select" "id" "locale" "na"
[8] "quoted_na" "quote" "comment" "trim_ws" "skip" "n_max" "guess_max"
[15] "name_repair" "num_threads" "progress" "show_col_types" "skip_empty_rows" "lazy"
col_namesμ col_types: μ΄ μ΄λ¦κ³Ό μ΄μ μ΄λ»κ² ꡬ문 λΆμν μ§λ₯Ό μ§μ
locale: μΈμ½λ© μ€μ κ³Ό μμμ κ΅¬λΆ κΈ°νΈ(β.β λλ β,β) λ±μ κ²°μ νλ λ° μ€μ
naμ quoted_na: κ²°μΈ‘κ°μΌλ‘ μ²λ¦¬ν λ¬Έμμ΄μ μ μ΄
trim_ws: μ μλ€μ 곡백μ μ κ±°ν ν ꡬ문 λΆμ
n_max: μ½μ μ΅λ ν μλ₯Ό μ€μ
guess_max: μ΄ μ νμ μΆμΈ‘ν λ μ¬μ©ν ν μλ₯Ό μ€μ
progress: μ§ν νμμ€μ νμν μ§ μ¬λΆλ₯Ό κ²°μ
read_fwf() ν¨μμμ κ°μ₯ μ€μν μΈμλ col_positionsμ΄λ€.
μ΄ μΈμλ λ°μ΄ν° μ΄μ΄ μμνκ³ λλλ μμΉλ₯Ό ν¨μμ μλ €μ£Όλ©°,
βfixed-width formatsβμ νμΌμ μ½μ λ μ¬μ©λλ€.
"x,y\n1,'a,b'"
[1] "x,y\n1,'a,b'"
read_delim()μ μ¬μ©ν κ²½μ°, κ΅¬λΆ λ¬Έμλ‘ β,βλ₯Ό μ§μ νκ³ quote μΈμλ₯Ό μ€μ ν΄μΌ νλ€.
x <- "x,y\n1,'a,b'"
read_delim(x, ",", quote = "'", show_col_types = FALSE)
λν read_csv()λ quote μΈμλ₯Ό μ§μνλ€.
read_csv(x, quote = "'", show_col_types = FALSE)
#1
read_csv("a,b\n1,2,3\n4,5,6")
Warning: One or more parsing issues, call `problems()` on your data frame for details, e.g.:
dat <- vroom(...)
problems(dat)Rows: 2 Columns: 2ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
dbl (1): a
num (1): b
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Warning: One or more parsing issues, see `problems()` for details
#> Rows: 2 Columns: 2
#> ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Delimiter: ","
#> dbl (1): a
#>
#> βΉ Use `spec()` to retrieve the full column specification for this data.
#> βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 2 Γ 2
#> a b
#> <dbl> <dbl>
#> 1 1 23
#> 2 4 56
λ κ°μ μ΄(aμ b)λ§ μ§μ λμ΄ μμ§λ§, κ° νμλ μΈ κ°μ κ°μ΄ μμ΅λλ€. κ·Έλμ λ§μ§λ§ μ΄ κ°μ΄ μλ¦°λ€.
#2
read_csv("a,b,c\n1,2\n1,2,3,4")
Warning: One or more parsing issues, call `problems()` on your data frame for details, e.g.:
dat <- vroom(...)
problems(dat)Rows: 2 Columns: 3ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
dbl (2): a, b
num (1): c
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Warning: One or more parsing issues, see `problems()` for details
#> Rows: 2 Columns: 3
#> ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Delimiter: ","
#> dbl (2): a, b
#>
#> βΉ Use `spec()` to retrieve the full column specification for this data.
#> βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 2 Γ 3
#> a b c
#> <dbl> <dbl> <dbl>
#> 1 1 2 NA
#> 2 1 2 34
ν€λμλ μΈ κ°μ μ΄μ΄ μμ§λ§, 첫 λ²μ§Έ νμλ λ κ°μ κ°λ§ μκ³ λ λ²μ§Έ νμλ λ€ κ°μ κ°μ΄ μλ€. 첫 λ²μ§Έ νμμλ c μ΄μ΄ κ²°μΈ‘μΉλ‘ μ€μ λκ³ , λ λ²μ§Έ νμμλ μΆκ°λ κ°μ΄ μλ¦°λ€.
#3
read_csv("a,b\n\"1")
Rows: 0 Columns: 2ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (2): a, b
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 0 Columns: 2
#> ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Delimiter: ","
#> chr (2): a, b
#>
#> βΉ Use `spec()` to retrieve the full column specification for this data.
#> βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 0 Γ 2
#> # β¦ with 2 variables: a <chr>, b <chr>
1μ΄λΌλ μ΄ κ°μ΄ μ΄λ¦Ό νμλ§ μκ³ λ«νμ§ μμκΈ° λλ¬Έμ μλν λ°κ° λΆλΆλͺ νλ€. μΈμ©μ΄ λ«νμ§ μμ aλ μ«μνμΌλ‘ μ²λ¦¬λκ³ , bλ κ²°μΈ‘μΉλ‘ μ€μ λλ€.
#4
read_csv("a,b\n1,2\na,b")
Rows: 2 Columns: 2ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (2): a, b
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 2 Columns: 2
#> ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Delimiter: ","
#> chr (2): a, b
#>
#> βΉ Use `spec()` to retrieve the full column specification for this data.
#> βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 2 Γ 2
#> a b
#> <chr> <chr>
#> 1 1 2
#> 2 a b
βaβμ βbβκ° μ«μκ° μλ λ¬Έμμ΄μ ν¬ν¨νκ³ μμΌλ―λ‘ λ¬ΈμνμΌλ‘ μ²λ¦¬λλ€. μ΄κ²μ΄ μλλ κ²μΌ μλ μκ³ , 1,2μ a,bκ° κ°μΌλ‘ μ§μ λκΈΈ μνλ κ²μΌ μλ μλ€.
#5
read_csv("a;b\n1;3")
Rows: 1 Columns: 1ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Delimiter: ","
chr (1): a;b
βΉ Use `spec()` to retrieve the full column specification for this data.
βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> Rows: 1 Columns: 1
#> ββ Column specification ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#> Delimiter: ","
#> chr (1): a;b
#>
#> βΉ Use `spec()` to retrieve the full column specification for this data.
#> βΉ Specify the column types or set `show_col_types = FALSE` to quiet this message.
#> # A tibble: 1 Γ 1
#> `a;b`
#> <chr>
#> 1 1;3
λ°μ΄ν°κ° β;βλ‘ κ΅¬λΆλμ΄ μλ€. μ΄ κ²½μ° read_csv2()λ₯Ό μ¬μ©νλ©΄ λ μ ν©νλ€.